package com.naton.mydemo.ui.act;

import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.naton.common.ui.BaseActivity;
import com.naton.mydemo.R;
import com.naton.mydemo.bean.User;
import com.naton.mydemo.databinding.ActivityBaseQuickAdapterBinding;

import java.util.ArrayList;
import java.util.List;

/**
 * @time: 2022/1/19
 * @author: lifuling
 * @version: v1.0
 * @file_desc:
 */
public class BaseQuickAdapterDemoActivity extends BaseActivity<ActivityBaseQuickAdapterBinding> {

    List<User> userList = new ArrayList<>();
    BaseQuickAdapter<User , BaseViewHolder> mAdapter;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initData();
        initView();
    }

    private void initData() {
        int count = 1;
        while (count < 30){
            User user = new User();
            user.companyName = "哈哈" + count;
            userList.add(user);
            count = count + 1;
        }
    }

    private void initView() {
        mAdapter = new BaseQuickAdapter<User , BaseViewHolder>(R.layout.item_base_quick_adapter , userList) {

            @Override
            protected void convert(@NonNull BaseViewHolder baseViewHolder, User user) {
                baseViewHolder.setText(R.id.tv , user.companyName);
            }
        };
        mBinding.mRecyclerView.setAdapter(mAdapter);
    }
}
